package com.meiborte;

import com.meiborte.dao.BookDao;
import com.meiborte.entity.Book;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class MyApp {
    public static void main(String[] args)throws Exception {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//        DataSource dataSource = context.getBean("dataSource", DataSource.class);
//        System.out.println(dataSource.getConnection());

//从IOC容器中获取对象
        BookDao bookDao = context.getBean("bookDao2", BookDao.class);
//        int m =bookDao.addBook(new Book().setTitle("Java123").setPrice(100).setQuantity(10));
//        System.out.println(m);

//        int m = bookDao.updateBook(new Book().setId(8).setTitle("kubectl").setPrice(100).setQuantity(10));
        int m = bookDao.deleteBook(8);
        System.out.println(m);
    }
}
